home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / include / camera.h < prev    next >
C/C++ Source or Header  |  1993-04-18  |  6KB  |  193 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9.  
  10. /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
  11.  
  12. #ifndef CAMERA_H
  13. #define CAMERA_H
  14.  
  15. #include "3d.h"
  16. #include "handle.h"
  17.  
  18. typedef struct Camera Camera;
  19.  
  20. /* Public Camera methods (more below): */
  21.  
  22. Camera *CamCreate( int attr1, ... );            
  23. Camera *CamSet( Camera *, int attr1, ... );        
  24. int    CamGet( Camera *, int attr, void *value);
  25. void    CamDelete( Camera * );                
  26. Camera *CamCopy( Camera *src, Camera *dst );        
  27. Camera *CamMerge( Camera *src, Camera *dst );
  28.  
  29. /* Camera attributes: */
  30.                 /* Set/Create type    Get type    */
  31. #define CAM_END        800    /* ---------------    --------    */
  32. #define CAM_PERSPECTIVE 801    /* int            int *        */
  33. #define CAM_C2W        802    /* Transform        Transform    */
  34. #define CAM_W2C        803    /* Transform        Transform    */
  35. #define CAM_FOV        804    /* float        float *        */
  36. #define CAM_HALFYFIELD    805    /* float        float *        */
  37. #define CAM_HALFFIELD    806    /* float        float *        */
  38. #define CAM_ASPECT    807    /* float        float *        */
  39. #define CAM_FOCUS    808    /* float        float *        */
  40. #define CAM_NEAR    809    /* float        float *        */
  41. #define CAM_FAR        810    /* float        float *        */
  42. #define CAM_STEREO    811    /* int            int *        */
  43. #define CAM_STEREOSEP    812    /* float        float *        */
  44. #define CAM_STEREOANGLE    813    /* float        float *        */
  45. #define CAM_STEREOEYE    814    /* int            int *        */
  46. #define    CAM_C2WHANDLE    815    /* Handle *        Handle **    */
  47. #define    CAM_W2CHANDLE    816    /* Handle *        Handle **    */
  48. #define CAM_STEREYES    817    /* Transform [2]    Transform [2]    */
  49. #define    CAM_STERHANDLES    818    /* Handle *[2]        Handle *[2]    */
  50. #define CAM_SPACE    819    /* int            int *        */
  51.  
  52. #define CAM_ABLOCK    820    /* void **ablock */
  53.  
  54. /*
  55.   CAM_END:        end of attribute list
  56.   CAM_PERSPECTIVE:    perspective (1) or ortho (0) projection (default:1)
  57.   CAM_C2W:        camera-to-world transform: <world> * C2W = <cam>
  58.   CAM_W2C:        world-to-camera transform (inverse of CAM_C2W)
  59.   CAM_C2WHANDLE:    Handle onto CAM_C2W
  60.   CAM_W2CHANDLE:    Handle onto CAM_W2C
  61.   CAM_FOV:        field of view (in degrees)
  62.   CAM_HALFYFIELD:    FOV half-width at z=1 (Y direction)
  63.   CAM_HALFFIELD:    min FOV half-width
  64.   CAM_ASPECT:        aspect ratio, X/Y
  65.   CAM_FOCUS:        nominal focal distance for perspec<->ortho
  66.   CAM_NEAR:        near clipping plane
  67.   CAM_FAR:        far clipping plane
  68.   CAM_STEREO:        stereo (1) or mono (0) (default:0)
  69.   CAM_STEREOSEP:    separation distance between stereo eyes
  70.   CAM_STEREOANGLE:    angle between stereo eyes (degrees)
  71.   CAM_STEREYES:        array of two transforms resp. for left & right eye,
  72.               applied as <world> * C2W * STEREYE * projection
  73.   CAM_STERHANDLES:    Handles for left and right eye transforms
  74.   CAM_STEREOEYE:    Which stereo eye selected: CAM_LEFT or CAM_RIGHT
  75.   CAM_SPACE:        TM_EUCLIDEAN, TM_HYPERBOLIC, or TM_SPHERICAL
  76.   */
  77.  
  78. #define    CAM_LEFT    0
  79. #define    CAM_RIGHT    1
  80.  
  81. /*
  82.  * Additional public Camera methods:
  83.  */
  84.  
  85. /* Reset to defaults */
  86. void    CamReset( Camera * );            
  87.  
  88. /*  return Camera's projection xform; doesn't change camera at all */
  89. void    CamViewProjection( Camera *, Transform ); 
  90.  
  91. /*  Complete cam world->proj xform; doesn't change camera at all */
  92. void    CamView( Camera *, Transform );    
  93.  
  94. /* Apply T to camtoworld xform */
  95. void    CamTransform( Camera *, Transform T );    
  96.  
  97. /* Rotate camera about X */
  98. void    CamRotateX( Camera *, float angle );    
  99.  
  100. /* Rotate about Y (radians) */
  101. void    CamRotateY( Camera *, float );        
  102.  
  103. /* Rotate about Z */
  104. void    CamRotateZ( Camera *, float );        
  105.  
  106. /* Translate X,Y,Z */
  107. void    CamTranslate( Camera *, float,float,float );    
  108.  
  109. /* Hyperbolic xlate */
  110. void    CamHypTranslate( Camera *, float,float,float, float );    
  111.  
  112. /* Parallax */
  113. void    CamStereoCompute( Camera *cam );             
  114.  
  115. /* Zoom in X,Y,Z */
  116. void    CamScale( Camera *, float,float,float );        
  117.  
  118. /* ??? */
  119. void    CamAlignZ( Camera *, float,float,float );        
  120.  
  121. /* Save to file */
  122. void    CamSave(Camera *, char *);
  123. void    CamFSave(Camera *, FILE *, char *);
  124.  
  125. /* Load from file */
  126. Camera  *CamLoad(Camera *, char *);
  127. Camera  *CamFLoad(Camera *, FILE *, char *);
  128.  
  129. /************************************************************************
  130.  * The following procedures are on death row; they will be taken out    *
  131.  * soon because they have been superceded by CamGet and CamSet          *
  132.  ************************************************************************/
  133.  
  134. /* Get object xform */
  135. void    CamCurrentPosition( Camera *, Transform );        
  136.  
  137. /*  Camera's world->camera xform (inverse of CamCurrentPosition) */
  138. void    CamViewWorld( Camera *, Transform ); 
  139.  
  140. /* Set "focal" length */
  141. void    CamFocus( Camera *, float focus );            
  142.  
  143. /* Get focal length */
  144. float    CamCurrentFocus( Camera * );            
  145.  
  146. /* Set X/Y aspect */
  147. void    CamFrameAspect( Camera *, float aspectratio );    
  148.  
  149. /* Get X/Y aspect */
  150. float    CamCurrentAspect( Camera * );            
  151.  
  152. /* camtoworld xform = T */
  153. void    CamTransformTo( Camera *, Transform T );    
  154.  
  155. /* Left/Right/Mono */
  156. void    CamStereoEye( Camera *cam, int whicheye );        
  157.  
  158. /* Set clip planes */
  159. void    CamClipping( Camera *, float near, float far );    
  160.  
  161. /* Get clipping */
  162. void    CamCurrentClipping( Camera *, float *near, float *far ); 
  163.  
  164. /* Set field: minfov/2 */
  165. void    CamHalfField( Camera *, float halffield );        
  166.  
  167. /* Set field: Yfov/2 */
  168. void    CamHalfYField( Camera *, float halfyfield );    
  169.  
  170. /* perspective/ortho */
  171. void    CamPerspective( Camera *, int perspective );    
  172.  
  173. /* or orthographic */
  174. int    CamIsPerspective( Camera * );            
  175.  
  176. /* Get fov/2 (max way) */
  177. float    CamCurrentHalfField( Camera * );            
  178.  
  179. /* Get fov/2 (Y dir) */
  180. float    CamCurrentHalfYField( Camera * );            
  181.  
  182. /* Get xfms, cur eye */
  183. int    CamCurrentStereo( Camera *, Transform leye, Transform reye );
  184.  
  185. void CamDefault(Camera *cam);
  186.  
  187. int CamStreamIn(Pool *p, Handle **hp, Camera **camp);
  188. int CamStreamOut(Pool *p, Handle *hp, Camera *cam);
  189.  
  190. void CamHandleScan( Camera *cam, int (*func)(), void *arg );
  191.  
  192. #endif /* !CAMERA_H */
  193.